package com.appspot.etao.model;

import javax.jdo.annotations.IdGeneratorStrategy;
import javax.jdo.annotations.IdentityType;
import javax.jdo.annotations.PersistenceCapable;
import javax.jdo.annotations.Persistent;
import javax.jdo.annotations.PrimaryKey;

import com.taobao.top.domain.TaobaokeShop;

@PersistenceCapable(identityType = IdentityType.APPLICATION)
public class TaobaokeShopModel extends BaseModel {

	private static final long serialVersionUID = -1107712810430702669L;
	
	@PrimaryKey
    @Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
    private Long id;
    
    /** 商品所属类别 （本地封装属性）*/
    @Persistent
	private String cid;

    /** 店铺用户名 */
    @Persistent
	private String userId;
    
    /** 店铺名称 */
    @Persistent
	private String shopTitle;
    
    /** 店铺推广地址 */
    @Persistent
	private String clickUrl;
    
    /** 淘宝客店铺佣金比率 */
    @Persistent
	private String shopCommission;
	
	private TaobaokeShop shop;

	public TaobaokeShopModel() {
		
	}
	
	public TaobaokeShopModel(TaobaokeShop shop, String cid) {
		this.cid = cid;
		
		setShop(shop);
	}
	
	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	public String getUserId() {
		return userId;
	}

	public void setUserId(String userId) {
		this.userId = userId;
	}

	public String getShopTitle() {
		return shopTitle;
	}

	public void setShopTitle(String shopTitle) {
		this.shopTitle = shopTitle;
	}

	public String getClickUrl() {
		return clickUrl;
	}

	public void setClickUrl(String clickUrl) {
		this.clickUrl = clickUrl;
	}

	public String getShopCommission() {
		return shopCommission;
	}

	public void setShopCommission(String shopCommission) {
		this.shopCommission = shopCommission;
	}

	public String getCid() {
		return cid;
	}

	public void setCid(String cid) {
		this.cid = cid;
	}

	public TaobaokeShop getShop() {
		return shop;
	}

	public void setShop(TaobaokeShop shop) {
		this.shop = shop;
		
		this.userId = shop.getUserId().toString();
		this.shopTitle = shop.getShopTitle();
		this.clickUrl = shop.getClickUrl();
		this.shopCommission = shop.getCommissionRate();
	}
	
	public String toString() {
		StringBuffer sb = new StringBuffer("");
		sb.append("[");
		sb.append(userId);
		sb.append(",");
		sb.append(shopTitle);
		sb.append(",");
		sb.append(clickUrl);
		sb.append(",");
		sb.append(shopCommission);
		sb.append("]");
		
		return sb.toString();
	}
	
	
}
